package com.example.springframeworklearning.propertyeditor.registrar;

import org.springframework.beans.PropertyEditorRegistrar;
import org.springframework.beans.PropertyEditorRegistry;
import com.example.springframeworklearning.domain.Order;
import com.example.springframeworklearning.domain.OrderItem;
import com.example.springframeworklearning.propertyeditor.LocalDateTimePropertyEditor;
import com.example.springframeworklearning.propertyeditor.OrderItemListPropertyEditor;

import java.time.LocalDateTime;

/**
 * 将所有的 PropertyEditor 封装到一个类中
 * 在controller 中可以按需使用，不用把每一个 PropertyEditor 都重复注册一遍
 * @author luo
 * @since 2022/9/19 16:30
 */
public class MyPropertyEditorRegistrar implements PropertyEditorRegistrar {

    @Override
    public void registerCustomEditors(PropertyEditorRegistry registry) {
        registry.registerCustomEditor(OrderItem.class, new OrderItemListPropertyEditor());
        registry.registerCustomEditor(LocalDateTime.class, new LocalDateTimePropertyEditor());
    }
}
